import Polyglot from 'node-polyglot'

export const translations = {
    'en_US': {
        kubernetes_cluster_basic_information: 'Kubernetes Cluster Basic Information',
        failed_to_connect_to_cluster: 'Failed to connect to cluster',
        target_resources_published_do_not_exist: 'The target resources {{kind}/{{name}} published do not exist in namespace {{namespace}}, please check the configuration',
        upcoming_release_to_online: 'Upcoming release of {{image}} to online resources',
        application_does_not_exist: 'The application {{kind}/{{name}} does not exist in namespace {{namespace}}. Please check the relevant application configuration in the cluster',
        deploy_changes_to_kubernetes_cluster: 'Deploy changes to Kubernetes cluster',
        resource_container_image_update_failed: 'Resource {{kind}}/{{name}}->Container {{containerName}} image update failed, please check configuration',
        print_the_current_task_execution_result: 'Print the current task execution result',
        publication_detection_timeout: 'Publication detection timeout, please check the application service configuration and running status',
        unable_to_find_the_image_to_publish: 'Unable to find the image to publish, please check the configuration',
        checking_the_publication_results: 'Start checking the publication results, wait at most {{rolloutTimeoutSeconds}} seconds, check {{checkCount}} times',
        check_retrieve: 'The {{i} th check, retrieve the Kubernetes Certificate again',
        check_retrieve_refresh_Kubernetes: '{{i}} th check, retrieve Kubernetes Certificate again',
        failed_to_obtain_kubernetes_certificate_file: 'Failed to obtain a valid Kubernetes certificate file. Please check the pipeline configuration and try again',
        verify_container_configuration: 'Verify Container Configuration',
        container_definitions: 'The current application {{name}} contains {{count}} container definitions',
    },
    'zh_CN': {
        kubernetes_cluster_basic_information: 'Kubernetes集群基本信息',
        failed_to_connect_to_cluster: '连接集群失败',
        target_resources_published_do_not_exist: '发布的目标资源 {{kind}}/{{name}}在命名空间{{namespace}}不存在，请检查配置',
        upcoming_release_to_online: '即将发布{{image}}到线上的资源',
        application_does_not_exist: '应用{{kind}}/{{name}}在命名空间{{namespace}}不存在，请到集群中检查相关应用配置',
        deploy_changes_to_kubernetes_cluster: '部署变更到Kubernetes集群',
        resource_container_image_update_failed: '资源{{kind}}/{{name}}->容器{{containerName}}镜像更新失败，请检查配置',
        print_the_current_task_execution_result: '打印当前任务执行结果',
        publication_detection_timeout: '发布检测超时，请检查应用服务配置和运行状态',
        unable_to_find_the_image_to_publish: '未找到要发布的镜像，请检查配置',
        checking_the_publication_results: '开始检查发布结果，最多等待{{rolloutTimeoutSeconds}}秒,检查{{checkCount}}次',
        check_retrieve: '第{{i}}次检查，重新获取 kubernetesCertificate',
        check_retrieve_refresh_Kubernetes: '第{{i}}次检查，重新获取 kubernetesCertificate',
        failed_to_obtain_kubernetes_certificate_file: '未获取到合法的Kubernetes证书文件，请检查流水线配置后再试',
        verify_container_configuration: '校验Container配置',
        container_definitions: '当前应用{{name}}中包含{{count}}个容器定义',
    }
}

const locale = process.env['PIPELINE_LOCALE'] === 'zh_CN' ? 'zh_CN' : 'en_US'
export const polyglot = new Polyglot({
    interpolation: {prefix: '{{', suffix: '}}'},
    phrases: translations[locale]
})